#include<head.h>

void *thread_2(void *arg)
{
    printf("thread_2 %d\n", *((int *)arg));
}
void *thread_1(void *arg)
{
    pthread_t tid[5];
    int arr[5] = {1,2,3,4,5};
    printf("thread_1\n");
    for(int i = 0; i < 5; i++)
    {
        if(0 != pthread_create(&tid[i], NULL, thread_2, (void *)&arr[i]))
        {
            printf("pthread_create error\n");
            return NULL;
        }
    }
    for(int i = 0; i < 5; i++)
    {
        pthread_join(tid[i], NULL); //阻塞回收
    }

}
int main(int argc, char const *argv[])
{
    pthread_t tid = 0;
    if(0 != pthread_create(&tid, NULL, thread_1, NULL))
    {
        printf("pthread_create error\n");
        return 0;
    }
    pthread_join(tid, NULL);
    return 0;
}
